package chpt07;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

public class ReadFileTryWithResources {
	public static void readFileTryWithResources(String fileName) {
		try (FileInputStream fin = new FileInputStream(fileName)) {
			// 文件读取操作
		} catch (FileNotFoundException e) {
			System.out.println(e.getMessage()); // 异常处理1
		} catch (IOException e) {
			e.printStackTrace(); // 异常处理2
		} finally {
			System.out.println("fin资源已被回收");
		}
	}

	public static void main(String[] args) {
		readFileTryWithResources("a.txt");
	}
}
